package com.xuelang.pipeline.entry.resource;

import com.xuelang.pipeline.app.resource.DictService;
import com.xuelang.pipeline.client.common.request.PageParam;
import com.xuelang.pipeline.client.common.result.ApiResult;
import com.xuelang.pipeline.client.common.result.PageRecord;
import com.xuelang.pipeline.client.resource.IDictService;
import com.xuelang.pipeline.client.resource.dto.DictDTO;
import com.xuelang.pipeline.client.resource.dto.DictQuery;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 字典服务web控制类
 *
 * @author xiwen.zxg
 * @since 2024/5/15
 */
@Slf4j
@RestController
@RequestMapping("/dict")
public class DictController implements IDictService {

    @Autowired
    private DictService dictService;

    @Override
    public ApiResult<PageRecord<DictDTO>> pageDictList(PageParam<DictQuery> dtoPageParam) {
        return ApiResult.success(dictService.pageList(dtoPageParam));
    }

    @Override
    public ApiResult<List<DictDTO>> conditionalDictList(DictQuery dictQuery) {
        return ApiResult.success(dictService.list(dictQuery));
    }

    @Override
    public ApiResult<Boolean> addDict(DictDTO dictDTO) {
        return ApiResult.success(dictService.add(dictDTO));
    }

    @Override
    public ApiResult<Boolean> updateDict(DictDTO dictDTO) {
        return ApiResult.success(dictService.update(dictDTO));
    }

    @Override
    public ApiResult<Boolean> deleteDict(Long id) {
        return ApiResult.success(dictService.delete(id));
    }

    @Override
    public ApiResult<DictDTO> queryDict(Long id) {
        return ApiResult.success(dictService.query(id));
    }
}